<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>综合能耗</span>
    </div>
    <div class="text item">
      <div id="ringlike" style="width: 100%;height: 400px"></div>
    </div>
  </el-card>

</template>

<script>
import {getEmissionOverall} from "@/api/dtct/dataCenter";

export default {
  name: "Synthetical",
  mounted(){
    this.initEchart();
  },
  methods:{
    // getData() {
    //   return new Promise((resolve, reject) => {
    //     getEmissionOverall().then(response => {
    //       resolve(response.data)
    //     });
    //   })
    // },
    initEchart(){
      // let data = this.getData()
      // data.then( res => {
        // let date = []
        // let totalPowerConsume = []
        // let totalWaterConsume = []
        // let totalOfficePowerConsume = []
        // let totalOfficeWaterConsume = []
        // let totalPrdPowerSave = []
        // for (let year in res) {
        //   let obj = res[year];
        //   date.push(year)
        //   totalPowerConsume.push(obj.totalPowerConsume);
        //   totalWaterConsume.push(obj.totalWaterConsume);
        //   totalOfficePowerConsume.push(obj.totalOfficePowerConsume);
        //   totalOfficeWaterConsume.push(obj.totalOfficeWaterConsume);
        //   totalPrdPowerSave.push(obj.totalProductPowerSave + obj.totalOfficePowerSave);
        // }
        let myChart = this.$echarts.init(document.getElementById('ringlike'));
        let option = {
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          legend: {
            show: true,
            top: "6%"
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
          },
          yAxis: {
            type: 'category',
            data: ['2018', '2019', '2020', '2021', '2022', '2023']
          },
          series: [
            {
              name: '生产耗电量',
              type: 'bar',
              data: [0,0,0,0,0,723000]
            },
            {
              name: '生产用水量',
              type: 'bar',
              data:  [49000, 48000, 48999, 48750, 47864, 45000]
            },
            {
              name: '办公耗电量',
              type: 'bar',
              data:  [180000, 180800, 188400, 189000, 189900, 100000]
            },
            {
              name: '办公用水量',
              type: 'bar',
              data:  [18203, 18203, 19203, 18203, 18203, 18203]
            },
            {
              name: '节点量',
              type: 'bar',
              data:  [350000, 340000, 330000, 320400, 340500, 330000]
            }
          ]
        };

        option && myChart.setOption(option);
      }
  }
}
</script>

<style scoped>

</style>
